<template>
  <div class="app-container">
    <!-- 功能区 -->
    <transition name="formFade">
      <el-card class="operate-container" shadow="never" v-if="showSearch">
        <el-form :inline="true" :model="listQuery" @submit.native.prevent>
          <el-form-item label="资源名称" class="form-item">
            <el-input v-model="listQuery.assetName" clearable class="filter-item" placeholder="资源名称"/>
          </el-form-item>
          <el-form-item label="开始日期:" class="form-item">
            <el-date-picker
              class="filter-item"
              v-model="listQuery.startDate"
              align="right"
              type="date"
              placeholder="选择开始日期"
              value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="结束日期:" class="form-item">
            <el-date-picker
              class="filter-item"
              v-model="listQuery.endDate"
              align="right"
              type="date"
              placeholder="选择结束日期"
              value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="状态:" class="form-item">
            <el-select placeholder="请选择" style="width:100%;" clearable v-model="listQuery.result"
                       class="form-select" :popper-append-to-body="false" popper-class="select-popper">
              <el-option :value="0" label="空闲"></el-option>
              <el-option :value="1" label="出租"></el-option>
              <el-option :value="2" label="停用"></el-option>
              <el-option :value="3" label="注销"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="form-item">
            <el-button size="mini" icon="el-icon-refresh" @click="colse">重置</el-button>
            <el-button type="primary" size="mini" icon="el-icon-search" @click="getList">查询</el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </transition>
    <div class="table_content">
      <headerSearch :showAdd="false"
                    @creRefresh="getList"
                    @isSearch="showSearch = !showSearch"></headerSearch>
      <!--表格渲染-->
      <el-table ref="table" v-loading="loading" :data="list" style="width: 100%;" border
                :header-cell-style="{background: '#F8F8F9',padding: '6px 0 !important',color: '#515a6e'}">
        <af-table-column prop="assetName" fixed="left" label="资源名称" />
        <af-table-column prop="address" label="资产地址" />
        <el-table-column prop="biddingStatus" label="招投标状态" min-width="120">
          <template slot-scope="scope">
            {{{'0':'未招标','1':'开始招标','2':'招标完成','3':'合同签定'}[scope.row.biddingStatus]}}
          </template>
        </el-table-column>
        <af-table-column prop="addUserName" label="录入用户名" />
        <el-table-column prop="leaseType" label="出租方式" min-width="120">
          <template slot-scope="scope">
            {{{'0':'招投标出租','1':'非招投标出租'}[scope.row.leaseType]}}
          </template>
        </el-table-column>
        <af-table-column prop="measure" label="面积(平方米)" />
        <af-table-column prop="orgName" label="所属使用权单位" />
        <af-table-column prop="property" label="产权性质" />
        <el-table-column prop="status" label="状态" >
          <template slot-scope="scope">
            {{{'0':'空闲','1':'出租','2':'停用','3':'注销'}[scope.row.status]}}
          </template>
        </el-table-column>
        <af-table-column prop="content" label="其它信息" />
        <af-table-column prop="remark" label="备注" />
        <af-table-column prop="addTime" label="资产录入时间" />
        <af-table-column align="center" fixed="right" label="操作">
          <template slot-scope="scope">
            <el-button class="btn" type="text" size="small"
                       @click="seeEdit(scope.$index,scope.row)">查看</el-button>
          </template>
        </af-table-column>
      </el-table>

      <!--分页-->
      <pagination v-show="total>0" :total="total"
                  :page.sync="listQuery.pageNum"
                  :limit.sync="listQuery.pageSize"
                  @pagination="getList" />
    </div>

  </div>
</template>

<script>
  import { doPost, doGet, doFile, orglistChild } from '@/api/index'
  import Pagination from '@/components/Pagination/index'
  import {statusList, scaleList} from '@/utils/validate'
  import headerSearch from '@/components/headerSearch/headerSearch'

  export default {
    name: "bidList",
    components: {Pagination, headerSearch},
    data() {
      return {
        loading: false,
        showSearch: true,
        list: [
          {assetName: '测试资源', biddingStatus: 0,measure: 150,leaseType: 0,status: 1}
        ],
        total: 0,
        listQuery: {
          pageNum: 1,
          pageSize: 20,
          assetName: '',
          startDate: '',
          endDate: '',
          result: ''
        },
        statusList,
        scaleList,
      }
    },
    created() {
      // this.getList()
    },
    methods: {
      colse() {
        this.listQuery = {
          pageNum: 1,
          pageSize: 20,
          assetName: '',
          startDate: '',
          endDate: '',
          result: ''
        }
      },
      getList() {
        this.loading = true
        doPost('asset/page',this.listQuery).then(res => {
          this.loading = false
          this.list = res.data.list
          this.total = res.data.total
        }).catch(error => {
          this.list = []
          this.total = 0
          this.loading = false
        })
      },
      //查看详情
      seeEdit(index, row) {
        this.$router.push({ name: 'productDetail', params: { id: row.id }})
      },
    },
  }
</script>

<style scoped>

</style>
